Bug 573067 - Intra-app dnd of text behavior on Windows is wrong
authorTor Lillqvist <tml@iki.fi>
Wed, 11 Mar 2009 14:09:13 +0000 (14:09 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Wed, 11 Mar 2009 14:09:13 +0000 (14:09 +0000)
2009-03-11  Tor Lillqvist  <tml@iki.fi>

Bug 573067 - Intra-app dnd of text behavior on Windows is wrong

* gdk/win32/gdkdnd-win32.c (local_send_motion) (gdk_drag_motion):
The default action should be move, not copy. Tweak how the
GdkDragAction fields in GdkDragContexts are changed. Seems to help
the problem.

Add more debugging printout for --gdk-debug=dnd to many functions.

* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkprivate-win32.h: (_gdk_win32_drag_protocol_to_string)
(_gdk_win32_drag_action_to_string): New functions for use in
debugging printouts.

svn path=/trunk/; revision=22522

ChangeLog
gdk/win32/gdkdnd-win32.c
gdk/win32/gdkmain-win32.c
gdk/win32/gdkprivate-win32.h

index 483e771f9d01d51e338741af1f6130672cbad9b6..c45f5ef09f5e30bdea67b7bce1eaa5b016489df3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2009-03-11  Tor Lillqvist  <tml@iki.fi>
+
+       Bug 573067 - Intra-app dnd of text behavior on Windows is wrong
+
+       * gdk/win32/gdkdnd-win32.c (local_send_motion) (gdk_drag_motion):
+       The default action should be move, not copy. Tweak how the
+       GdkDragAction fields in GdkDragContexts are changed. Seems to help
+       the problem.
+
+       Add more debugging printout for --gdk-debug=dnd to many functions.
+
+       * gdk/win32/gdkmain-win32.c
+       * gdk/win32/gdkprivate-win32.h: (_gdk_win32_drag_protocol_to_string)
+       (_gdk_win32_drag_action_to_string): New functions for use in
+       debugging printouts.
+       
 2009-03-11  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkdnd-win32.c: Use G_DEFINE_TYPE. Some debugging
index bc1a2c5af63da5d63f4a700561010fa6b45b8abf..5b6e0f6946c9aa0240959cdd30697c673dff4bbb 100644 (file)
@@ -1080,6 +1080,10 @@ local_send_leave (GdkDragContext *context,
 {
   GdkEvent tmp_event;
   
+  GDK_NOTE (DND, g_print ("local_send_leave: context=%p current_dest_drag=%p\n",
+                         context,
+                         current_dest_drag));
+
   if ((current_dest_drag != NULL) &&
       (current_dest_drag->protocol == GDK_DRAG_PROTO_LOCAL) &&
       (current_dest_drag->source_window == context->source_window))
@@ -1105,6 +1109,10 @@ local_send_enter (GdkDragContext *context,
   GdkDragContextPrivateWin32 *private;
   GdkDragContext *new_context;
 
+  GDK_NOTE (DND, g_print ("local_send_enter: context=%p current_dest_drag=%p\n",
+                         context,
+                         current_dest_drag));
+
   private = PRIVATE_DATA (context);
   
   if (current_dest_drag != NULL)
@@ -1149,6 +1157,10 @@ local_send_motion (GdkDragContext *context,
 {
   GdkEvent tmp_event;
   
+  GDK_NOTE (DND, g_print ("local_send_motion: context=%p current_dest_drag=%p\n",
+                         context,
+                         current_dest_drag));
+
   if ((current_dest_drag != NULL) &&
       (current_dest_drag->protocol == GDK_DRAG_PROTO_LOCAL) &&
       (current_dest_drag->source_window == context->source_window))
@@ -1160,7 +1172,6 @@ local_send_motion (GdkDragContext *context,
       tmp_event.dnd.time = time;
 
       current_dest_drag->suggested_action = action;
-      current_dest_drag->actions = current_dest_drag->suggested_action;
 
       tmp_event.dnd.x_root = x_root;
       tmp_event.dnd.y_root = y_root;
@@ -1179,7 +1190,11 @@ local_send_drop (GdkDragContext *context,
                 guint32         time)
 {
   GdkEvent tmp_event;
-  
+
+  GDK_NOTE (DND, g_print ("local_send_drop: context=%p current_dest_drag=%p\n",
+                         context,
+                         current_dest_drag));
+
   if ((current_dest_drag != NULL) &&
       (current_dest_drag->protocol == GDK_DRAG_PROTO_LOCAL) &&
       (current_dest_drag->source_window == context->source_window))
@@ -1417,11 +1432,36 @@ gdk_drag_motion (GdkDragContext *context,
 
   g_return_val_if_fail (context != NULL, FALSE);
 
-  GDK_NOTE (DND, g_print ("gdk_drag_motion\n"));
+  context->actions = possible_actions;
+  GDK_NOTE (DND, g_print ("gdk_drag_motion: protocol=%s\n"
+                         " suggested_action=%s, possible_actions=%s\n"
+                         " context=%p:actions=%s, suggested_action=%s, action=%s\n",
+                         _gdk_win32_drag_protocol_to_string (protocol),
+                         _gdk_win32_drag_action_to_string (suggested_action),
+                         _gdk_win32_drag_action_to_string (possible_actions),
+                         context,
+                         _gdk_win32_drag_action_to_string (context->actions),
+                         _gdk_win32_drag_action_to_string (context->suggested_action),
+                         _gdk_win32_drag_action_to_string (context->action)));
+
 
   private = PRIVATE_DATA (context);
   
-  if (context->dest_window != dest_window)
+  if (context->dest_window == dest_window)
+    {
+      GdkDragContext *dest_context;
+                   
+      dest_context = gdk_drag_context_find (FALSE,
+                                           context->source_window,
+                                           dest_window);
+
+      if (dest_context)
+       dest_context->actions = context->actions;
+
+      context->suggested_action = suggested_action;
+    }
+  else
     {
       GdkEvent temp_event;
 
@@ -1469,10 +1509,6 @@ gdk_drag_motion (GdkDragContext *context,
 
       gdk_event_put (&temp_event);
     }
-  else
-    {
-      context->suggested_action = suggested_action;
-    }
 
   /* Send a drag-motion event */
 
@@ -1498,9 +1534,23 @@ gdk_drag_motion (GdkDragContext *context,
            }
        }
       else
-       return TRUE;
+       {
+         GDK_NOTE (DND, g_print (" returning TRUE\n"
+                                 " context=%p:actions=%s, suggested_action=%s, action=%s\n",
+                                 context,
+                                 _gdk_win32_drag_action_to_string (context->actions),
+                                 _gdk_win32_drag_action_to_string (context->suggested_action),
+                                 _gdk_win32_drag_action_to_string (context->action)));
+         return TRUE;
+       }
     }
 
+  GDK_NOTE (DND, g_print (" returning FALSE\n"
+                         " context=%p:actions=%s, suggested_action=%s, action=%s\n",
+                         context,
+                         _gdk_win32_drag_action_to_string (context->actions),
+                         _gdk_win32_drag_action_to_string (context->suggested_action),
+                         _gdk_win32_drag_action_to_string (context->action)));
   return FALSE;
 }
 
@@ -1558,6 +1608,14 @@ gdk_drag_status (GdkDragContext *context,
 
   private = PRIVATE_DATA (context);
 
+  GDK_NOTE (DND, g_print ("gdk_drag_status: action=%s\n"
+                         " context=%p:actions=%s, suggested_action=%s, action=%s\n",
+                         _gdk_win32_drag_action_to_string (action),
+                         context,
+                         _gdk_win32_drag_action_to_string (context->actions),
+                         _gdk_win32_drag_action_to_string (context->suggested_action),
+                         _gdk_win32_drag_action_to_string (context->action)));
+                         
   context->action = action;
 
   src_context = gdk_drag_context_find (TRUE,
index 5be01631ac3b863918b0dc158da37a71a8863091..4d6e0de6481ca3427b5e5a772226b26366c57431 100644 (file)
@@ -477,6 +477,26 @@ _gdk_win32_line_style_to_string (GdkLineStyle line_style)
   return NULL; 
 }
 
+gchar *
+_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol)
+{
+  switch (protocol)
+    {
+#define CASE(x) case GDK_DRAG_PROTO_##x: return #x
+      CASE (MOTIF);
+      CASE (XDND);
+      CASE (ROOTWIN);
+      CASE (NONE);
+      CASE (WIN32_DROPFILES);
+      CASE (OLE2);
+      CASE (LOCAL);
+#undef CASE
+    default: return static_printf ("illegal_%d", protocol);
+    }
+  /* NOTREACHED */
+  return NULL; 
+}
+
 gchar *
 _gdk_win32_gcvalues_mask_to_string (GdkGCValuesMask mask)
 {
@@ -656,6 +676,30 @@ _gdk_win32_window_pos_bits_to_string (UINT flags)
   return static_printf ("%s", buf);  
 }
 
+gchar *
+_gdk_win32_drag_action_to_string (GdkDragAction actions)
+{
+  gchar buf[100];
+  gchar *bufp = buf;
+  gchar *s = "";
+
+  buf[0] = '\0';
+
+#define BIT(x)                                         \
+  if (actions & GDK_ACTION_ ## x)                              \
+    (bufp += sprintf (bufp, "%s" #x, s), s = "|")
+
+  BIT (DEFAULT);
+  BIT (COPY);
+  BIT (MOVE);
+  BIT (LINK);
+  BIT (PRIVATE);
+  BIT (ASK);
+#undef BIT
+
+  return static_printf ("%s", buf);  
+}
+
 gchar *
 _gdk_win32_rop2_to_string (int rop2)
 {
index bc54e00dd3fa94b54e2be87fdef30d866177af8d..810a28a7aa7fc11b11e6468e473a8b9f247ce769 100644 (file)
@@ -314,11 +314,13 @@ gchar *_gdk_win32_fill_style_to_string (GdkFill      fill);
 gchar *_gdk_win32_function_to_string   (GdkFunction  function);
 gchar *_gdk_win32_join_style_to_string (GdkJoinStyle join_style);
 gchar *_gdk_win32_line_style_to_string (GdkLineStyle line_style);
+gchar *_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol);
 gchar *_gdk_win32_gcvalues_mask_to_string (GdkGCValuesMask mask);
 gchar *_gdk_win32_window_state_to_string (GdkWindowState state);
 gchar *_gdk_win32_window_style_to_string (LONG style);
 gchar *_gdk_win32_window_exstyle_to_string (LONG style);
 gchar *_gdk_win32_window_pos_bits_to_string (UINT flags);
+gchar *_gdk_win32_drag_action_to_string (GdkDragAction actions);
 gchar *_gdk_win32_drawable_description (GdkDrawable *d);
 
 gchar *_gdk_win32_rop2_to_string       (int          rop2);